#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 2e5 + 10;
long long a[N], c, n;
int main()
{
    cin >> n >> c;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    long long ret = 0;
    for (int i = 2; i <= n; i++)
    {
        long long b = a[i] - c;
        ret += upper_bound(a + 1, a + i, b) - lower_bound(a + 1, a + i, b);
    }
    cout << ret;
    return 0;
}